home *** CD-ROM | disk | FTP | other *** search
/ Gekkan Dennou Club 145 / Gekkan Dennou Club - 2000.6 Vol. 145 (Japan).7z / Gekkan Dennou Club - 2000.6 Vol. 145 (Japan) (Track 1).bin / games / spassion / source.lzh / SOURCE / SPASSION.C < prev    next >
Text File  |  2000-03-31  |  22KB  |  866 lines

  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <doslib.h>
  4. #include <iocslib.h>
  5. #include <apic.h>
  6. #include <XSP2lib.H>
  7. #include <PCM8Afnc.H>
  8.  
  9. #define GLOBAL_DEFINE        /* グローバル変数を確保する */
  10. #include "SPASSION.H"
  11. #include "PLAYER.H"
  12. #include "SHOT.H"
  13. #include "ENEMY.H"
  14. #include "ESHOT.H"
  15. #include "EFFECT.H"
  16. #include "ENTRY.H"
  17. #include "BG.H"
  18. #include "SOUND.H"
  19. #include "SUB.H"
  20.  
  21. #define MAX_LEVEL        2
  22. #define MAX_LEFT        9
  23.  
  24. void    Disp( void );
  25.  
  26. static char        last_stage=0,stage_select=0;
  27. static short    ret_title_flag=0,init_title_flag=1;
  28. static short    pause_flag=0;            /* =!0 なら一時停止中 */
  29. static short    left1=3,left2=3;        /* デフォルトの残機数 */
  30. static short    cur_x=0,cur_y=0;
  31. short    cur0_bg[]={0x00,0x01,0x02,0x03,0x04,0x04,0x03,0x02,0x01,0x00,-1};
  32. short    cur1_bg[]={0x05,0x06,0x07,0x08,0x09,0x09,0x08,0x07,0x06,0x05,0x02,-1};
  33. enum {
  34.     CONFIG_LEVEL = 0,
  35.     CONFIG_LEFT_1P,
  36. /*    CONFIG_LEFT_2P,*/
  37.     CONFIG_BT_SWAP_1P,
  38.     DUM1,
  39. /*    CONFIG_BT_SWAP_2P,*/
  40. /*    DUM2,*/
  41.     CONFIG_MUSIC,
  42.     CONFIG_SE,
  43.     CONFIG_XSP,
  44.     CONFIG_DISP,
  45.     CONFIG_EXIT
  46. };
  47. enum { START = 0,CONTINUE,CONFIG,END };
  48. static short end_stage_work=0;
  49. static short game_over_work=0;
  50.  
  51. void VdispRoutine( void )
  52. {
  53.     static short x1=0-5*16,x2=255,con=15,count=0;
  54.  
  55.     switch (game_state){
  56.     case END_STAGE:
  57.         if(pause_flag)break;
  58.         switch ( end_stage_work ){
  59.         case 0:
  60.             x1=0-5*16;x2=255;
  61.             player[0].vx=0;player[0].vy=0;
  62.             player[1].vx=0;player[1].vy=0;
  63.             player[0].state=PLAYER_LAST;
  64.             player[1].state=PLAYER_LAST;
  65.             player[0].dead_count=2;        /*PLAYER_LASTでの動作カウンタ*/
  66.             player[1].dead_count=2;        /*PLAYER_LASTでの動作カウンタ*/
  67.             end_stage_work++;
  68.         case 1:            /*文字列入場*/
  69.             PutBGStr( x1+= 8, 16*7, "STAGE", INFO_MOJI);
  70.             if( x1 > 128-5*16/2 ){
  71.                 x1=128-5*16/2;
  72.                 end_stage_work++;
  73.             }
  74.             break;
  75.         case 2:            /*文字列入場*/
  76.             PutBGStr( x1    , 16*7, "STAGE", INFO_MOJI);
  77.             PutBGStr( x2-= 8, 16*9, "CLEAR!", INFO_MOJI);
  78.             if( x2 < 128-5*16/2 ){
  79.                 x2=128-5*16/2;
  80.                 end_stage_work++;
  81.             }
  82.             break;
  83.         case 3:            /*プレイヤーが画面から出るのを待つ*/
  84.             PutBGStr( x1, 16*7, "STAGE", INFO_MOJI);
  85.             PutBGStr( x2, 16*9, "CLEAR!", INFO_MOJI);
  86.             if( player[0].state==PLAYER_WAIT && (count++> 60*1) && 
  87.                 (( play_mode == MODE_2P && player[1].state==PLAYER_WAIT )
  88.                 ||play_mode==MODE_1P)
  89.             ){
  90.                 count=0;
  91.                 end_stage_work++;
  92.             }
  93.             break;
  94.         case 4:            /*文字列退場*/
  95.             PutBGStr( x1+= 8, 16*7, "STAGE", INFO_MOJI);
  96.             PutBGStr( x2-= 8, 16*9, "CLEAR!", INFO_MOJI);
  97.             if( x1>255 && x2<-16*6 )
  98.                 end_stage_work++;
  99.             break;
  100.         case 5:
  101.             CONTRAST(con--);
  102.             if( CONTRAST(-1) == 0 )
  103.                 end_stage_work++;
  104.             break;
  105.         case 6:
  106.             if( count++> 30*1 ){
  107.                 count=0;
  108.                 player[0].state=PLAYER_APPEAR;
  109.                 player[1].state=PLAYER_APPEAR;
  110.                 game_state=IN_GAME;
  111.                 end_stage_work=0;
  112.                 entry_counter_stop = 0;    /* エントリーカウンター停止解除 */
  113.                 x1=0;x2=255;
  114.                 con=15;
  115.                 if( ++stage>=STAGES ){
  116.                     stage=STAGES-1;
  117.                     game_state=ENDING;
  118.                     game_over_state = GAME_COMPLETE;
  119.                     last_stage=0;
  120.                 }
  121.                 xsp_vsyncint_off();
  122.             }
  123.         }
  124.     break;
  125.     case IN_GAME_OVER:
  126.         if(pause_flag)break;
  127.         switch ( game_over_work ){
  128.         case 0:
  129.             PlayBGM( MUSIC_GAME_OVER );
  130.             x1=0-5*16;x2=255;
  131.             game_over_work++;
  132.         case 1:            /*文字列入場*/
  133.             PutBGStr( x1+= 8, 16*7, "GAME", INFO_MOJI);
  134.             if( x1 > 128-4*16/2 ){
  135.                 x1=128-4*16/2;
  136.                 game_over_work++;
  137.             }
  138.             break;
  139.         case 2:            /*文字列入場*/
  140.             PutBGStr( x1    , 16*7, "GAME", INFO_MOJI);
  141.             PutBGStr( x2-= 8, 16*9, "OVER!", INFO_MOJI);
  142.             if( x2 < 128-4*16/2 ){
  143.                 x2=128-4*16/2;
  144.                 game_over_work++;
  145.             }
  146.             break;
  147.         case 3:            /*ちょっと待つ*/
  148.             PutBGStr( x1, 16*7, "GAME", INFO_MOJI);
  149.             PutBGStr( x2, 16*9, "OVER!", INFO_MOJI);
  150.             if( count++> 60*1 ){
  151.                 game_over_work++;
  152.                 count=0;
  153.             }
  154.             break;
  155.         case 4:            /*文字列退場*/
  156.             PutBGStr( x1+= 8, 16*7, "GAME", INFO_MOJI);
  157.             PutBGStr( x2-= 8, 16*9, "OVER!", INFO_MOJI);
  158.             if( x1>255 && x2<-16*5 )
  159.                 game_over_work++;
  160.             break;
  161.         case 5:            /*ちょっと待つ*/
  162.             if( count++> 60*1 ){
  163.                 game_over_work++;
  164.                 count=0;
  165.             }
  166.             break;
  167.         case 6:            /* 画面フェードアウト */
  168.             CONTRAST(con--);
  169.             if( CONTRAST(-1) == 0 )
  170.                 game_over_work++;
  171.             break;
  172.         case 7:
  173.             if( count++> 30*1 ){
  174.                 count=0;
  175.                 game_state=IN_TITLE;
  176.                 game_over_work=0;
  177.                 game_over_state=GAME_OVER;
  178.                 con=15;
  179.                 x1=0;x2=255;
  180.                 CONTRAST(15);
  181.                 xsp_vsyncint_off();
  182.             }
  183.         }
  184.     }
  185. }
  186.  
  187. /*ステージ開始時の処理*/
  188. void    InitStage( void )
  189. {
  190.     unsigned short *pal=(unsigned short *)0xE82220;
  191.     short    i;
  192.     char    *stage_pic[STAGES*2]={
  193.         "PIC/STAGE1_0.PIC","PIC/STAGE1_1.PIC",
  194.         "PIC/STAGE2.PIC",  "PIC/STAGE2.PIC",
  195.         "PIC/STAGE3_0.PIC","PIC/STAGE3_1.PIC",
  196.         "PIC/STAGE4_0.PIC","PIC/STAGE4_1.PIC",
  197.     };
  198.     char    *stage_map[STAGES]={
  199.         "BG/STAGE01.MAP",
  200.         "BG/STAGE02.MAP",
  201.         "BG/STAGE03.MAP",
  202.         "BG/STAGE04.MAP",
  203.     };
  204.     last_stage=stage;
  205.  
  206.     BGCTRLST(1, 1, 0);            /* BG1表示OFF */
  207.     VPAGE(0);                    /* 表示を消す */
  208.     HOME( 0, 0 ,0 );
  209.     HOME( 1, 0 ,0 );
  210.     APAGE(1);apic_load(stage_pic[stage*2]  ,0,0);
  211.     APAGE(0);apic_load(stage_pic[stage*2+1],0,0);
  212.     VPAGE(3);                /* 表示 */
  213.  
  214.     LoadMapFile(stage_map[stage], &bg_map[stage][0], sizeof (short), 32 * 32 * 6);
  215.     for(i=0;i<16;i++)
  216.         *(pal++)=bg_pal[stage][i];
  217.     for(i=0;i<256;i++)
  218.         SP_DEFCG(i, 0, &bg_sp[stage][i*32]);
  219.     SetBG(0,0);
  220.     BGCTRLST(1, 1, 1);            /* BG1表示ON */
  221.  
  222.      gr1_x=0; gr1_y=0; gr1_vx=32768;gr1_vy=0;
  223.      gr2_x=0; gr2_y=0; gr2_vx=21845;gr2_vy=0;
  224.     map_x=0;map_y=0;map_vx=DOT_RATE/4;map_vy=0;
  225.     game_state=IN_GAME;
  226.     CONTRAST(15);
  227.     InitShot();
  228.     InitEnemy();
  229.     InitEShot();
  230.     InitEntry();
  231.     InitEffect();
  232.     while( CONTRAST(-1) != 15 );
  233. }
  234.  
  235. void Game( void )
  236. {
  237.     short    x1=16*5+8,x2=16*5-8,i=15,gx1=0,gx2=512;
  238.     void    Ending( void );
  239.     short    Pause( void );
  240.  
  241.     FadeOut( 48 );
  242.     InitPlayer( &player[0] );player[0].num = 0;        /* プレイヤーの番号 */
  243.     InitPlayer( &player[1] );player[1].num = 1;        /* プレイヤーの番号 */
  244.     ret_title_flag=0;
  245.     player[0].left=left1-1;
  246.     player[1].left=left2-1;
  247.     while( gx1<256 ){
  248.         PutBGStr( x1    , 16* 9, "START", INFO_MOJI );
  249.         PutBGStr( x2    , 16*10, "CONTNUE", INFO_MOJI );
  250.         PutBGStr( x1-=10, 16*11, "CONFIG", INFO_MOJI );
  251.         PutBGStr( x2+=10, 16*12, "END", INFO_MOJI );
  252.         xsp_vsync( 1 );
  253.         HOME( 2, gx1+=10, 0 );
  254.         HOME( 1, gx2-=10, 0 );
  255.         xsp_out();
  256.     }
  257.     InitShot();
  258.     InitEnemy();
  259.     InitEShot();
  260.     InitEntry();
  261.     InitEffect();
  262.     i=15;
  263.     while( CONTRAST(-1) != 0 ){
  264.         xsp_vsync( 1 );
  265.         CONTRAST(--i);
  266.     }
  267.  
  268.     while(game_over_state == GAME_PLAY){
  269.         short    x,y;
  270.  
  271.         MoveEntry();                    /* 敵出現、イベント発生 */
  272.  
  273.         MovePlayer( &player[0] );        /* 1P自機移動 */
  274.         if( play_mode == MODE_2P )
  275.             MovePlayer( &player[1] );    /* 2P自機移動 */
  276.  
  277.         MoveShot();                        /* 自弾移動 */
  278.  
  279.         MoveEnemy();                    /* 敵機移動 */
  280.  
  281.         MoveEShot();                    /* 敵弾移動 */
  282.  
  283.         MoveEffect();                    /* エフェクト処理 */
  284.  
  285.         map_x+=map_vx;
  286.         {
  287.             int        mx;
  288.             if( map_x > (mx=((32*5*8)<<16)) )
  289.                 map_x = mx;
  290.         }
  291.         bg_x=map_x>>16;
  292.         bg_y=map_y>>16;
  293.         x=bg_x/8;
  294.         y=bg_y/8;
  295.         for(i=31;i>=0;i--)
  296.             BGTEXTST(1,(x+32)&63,(y+i)&63,GetBG(x+32,y+i));
  297.         bg_x&=0x1FF;bg_y&=0x1FF;
  298. /*        BGSCRLST( 1,bg_x&0x1FF,bg_y&0x1FF );*/    /* vsyncを待たなくてもちらつかないようだけど、一応 */
  299. /*        ScrollBG();*/                        /* BGスクロール */
  300. /*        ScrollBG();を使わないのは、今回右にしかスクロールしないから*/
  301.  
  302.         gr1_x+=gr1_vx;gr1_y+=gr1_vy;        /* 背景スクロール */
  303.         gr2_x+=gr2_vx;gr2_y+=gr2_vy;
  304.  
  305.         if( BITSNS(0x00) & BIT(0x01) ){            /* ESCが押されたらPAUSE */
  306.             if( !Pause() ){
  307.                 ret_title_flag=1;
  308.                 break;
  309.             }
  310.         }else
  311.             Disp();            /* 表示 */
  312.  
  313.         PlaySE();            /* 効果音 */
  314.  
  315. #if 0
  316.         /* C キーでテキスト消去(デバッグ用) */
  317.         if( BITSNS(0x05) & BIT(4) )
  318.             B_CLR_AL();
  319. #endif
  320.     }
  321.     if(game_over_state == GAME_COMPLETE)
  322.         Ending();
  323. }
  324.  
  325. void Config( void )
  326. {
  327.     char    joy=0,cur_y=0,cur_anim=0;
  328.     char    key_flag=0,button_flag=0,kettei_flag=0,start_flag=1,end_flag=0,break_flag=0;
  329.     short    x1=256+16,x2=-256+16,tx1=16*5,tx2=16*5;
  330.     short    music=0,se=1;
  331.  
  332.     while( tx2<256+16 ){
  333.         PutBGStr( tx1    , 16* 9, "START", INFO_MOJI );
  334.         PutBGStr( tx2    , 16*10, "CONTNUE", INFO_MOJI );
  335.         PutBGStr( tx1-=10, 16*11, "CONFIG", INFO_MOJI );
  336.         PutBGStr( tx2+=10, 16*12, "END", INFO_MOJI );
  337.         xsp_vsync( 1 );
  338.         xsp_out();
  339.     }
  340.     FadeOut( 48 );
  341.     PlayBGM( MUSIC_CONFIG );
  342.     while(1){
  343.         if( !kettei_flag ){
  344.             joy=GetKey( 0,player[0].button_swap );
  345.  
  346.             if( !key_flag ){
  347.                 switch (joy){
  348.                 case 1:                    /* 上 */
  349.                     SetSE(SE_PIN);
  350.                     cur_y--;
  351.                     if( cur_y == DUM1 )cur_y=CONFIG_BT_SWAP_1P;
  352. /*                    if( cur_y == DUM2 )cur_y=CONFIG_BT_SWAP_2P;*/
  353.                     if( cur_y < CONFIG_LEVEL )cur_y=CONFIG_EXIT;
  354.                     break;
  355.                 case 2:                    /* 下 */
  356.                     SetSE(SE_PIN);
  357.                     cur_y++;
  358. /*                    if( cur_y == DUM1 )cur_y=CONFIG_BT_SWAP_2P;*/
  359.                     if( cur_y == DUM1 )cur_y=CONFIG_MUSIC;
  360. /*                    if( cur_y == DUM2 )cur_y=CONFIG_MUSIC;*/
  361.                     if( cur_y > CONFIG_EXIT )cur_y=CONFIG_LEVEL;
  362.                 }
  363.             }
  364.  
  365.             switch (cur_y){
  366.             case CONFIG_LEVEL:                /* 難易度 */
  367.                 if( joy == KEY_RIGHT && !key_flag ){
  368.                     level++;
  369.                     if( level > MAX_LEVEL )level=0;
  370.                 }
  371.                 if( joy == KEY_LEFT && !key_flag ){
  372.                     level--;
  373.                     if( level < 0 )level=MAX_LEVEL;
  374.                 }
  375.                 break;
  376.             case CONFIG_LEFT_1P:                /* 1P残機 */
  377.                 if( joy == KEY_RIGHT && !key_flag ){
  378.                     left1++;
  379.                     if( left1 > MAX_LEFT )left1=1;
  380.                 }
  381.                 if( joy == KEY_LEFT && !key_flag ){
  382.                     left1--;
  383.                     if( left1 < 1 )left1=MAX_LEFT;
  384.                 }
  385.                 break;
  386. #if 0
  387.             case CONFIG_LEFT_2P:                /* 2P残機 */
  388.                 if( joy == KEY_RIGHT && !key_flag ){
  389.                     left2++;
  390.                     if( left2 > MAX_LEFT )left2=1;
  391.                 }
  392.                 if( joy == KEY_LEFT && !key_flag ){
  393.                     left2--;
  394.                     if( left2 < 1 )left2=MAX_LEFT;
  395.                 }
  396.                 break;
  397. #endif
  398.             case CONFIG_BT_SWAP_1P:                /* 1Pボタン入れ換え */
  399.                 if( (joy == KEY_RIGHT||joy == KEY_LEFT) && !key_flag ){
  400.                     if( player[0].button_swap == OFF )player[0].button_swap=ON;
  401.                     else player[0].button_swap=OFF;
  402.                 }
  403.                 break;
  404. #if 0
  405.             case CONFIG_BT_SWAP_2P:                /* 2Pボタン入れ換え */
  406.                 if( (joy == KEY_RIGHT||joy == KEY_LEFT) && !key_flag ){
  407.                     if( player[1].button_swap == OFF )player[1].button_swap=ON;
  408.                     else player[1].button_swap=OFF;
  409.                 }
  410.                 break;
  411. #endif
  412.             case CONFIG_MUSIC:                /* 音楽 */
  413.                 if( joy == KEY_RIGHT && !key_flag ){
  414.                     music++;
  415.                     if( music > MAX_MUSIC-1 )music=0;
  416.                 }
  417.                 if( joy == KEY_LEFT && !key_flag ){
  418.                     music--;
  419.                     if( music < 0 )music=MAX_MUSIC-1;
  420.                 }
  421.                 if( joy & B_BUTTON && !button_flag ){
  422. /*                    void    ChangeZPD( short num );
  423.                     if( music == MAX_MUSIC-1 )
  424.                         ChangeZPD( 1 );
  425. */
  426.                     PlayBGM(music);
  427. /*                    if( music == MAX_MUSIC-1 )
  428.                         ChangeZPD( 0 );
  429. */
  430.                 }
  431.                 break;
  432.             case CONFIG_SE:                /* 効果音 */
  433.                 if( joy == KEY_RIGHT && !key_flag ){
  434.                     se++;
  435.                     if( se > MAX_SE-1-1 )se=1;
  436.                 }
  437.                 if( joy == KEY_LEFT && !key_flag ){
  438.                     se--;
  439.                     if( se < 1 )se=MAX_SE-1-1;
  440.                 }
  441.                 if( joy & B_BUTTON && !button_flag ){
  442.                     SetSE(se);
  443.                 }
  444.                 break;
  445.             case CONFIG_XSP:                /* XSPの表示レベル */
  446.                 if( joy == KEY_RIGHT && !key_flag ){
  447.                     xsp_mode_num++;
  448.                     if( xsp_mode_num > 3 )xsp_mode_num=1;
  449.                 }
  450.                 if( joy == KEY_LEFT && !key_flag ){
  451.                     xsp_mode_num--;
  452.                     if( xsp_mode_num < 1 )xsp_mode_num=3;
  453.                 }
  454.                 break;
  455.             case CONFIG_DISP:                /* 表示負荷レベル */
  456.                 if( (joy == KEY_RIGHT || joy == KEY_LEFT) && !key_flag ){
  457.                     if( disp_level == DISP_LEVEL_HIGH )disp_level=DISP_LEVEL_MID;
  458.                     else if( disp_level == DISP_LEVEL_MID )disp_level=DISP_LEVEL_HIGH;
  459.                 }
  460.                 break;
  461.             case CONFIG_EXIT:                /* 出口 */
  462.                 if( joy & B_BUTTON && !button_flag ){
  463.                     SetSE(SE_PON);
  464.                     cur_anim=0;
  465.                     kettei_flag=1;
  466. /*                    break;*/
  467.                 }
  468.                 break;
  469.             }
  470.         }
  471.         if( joy & 0x0F )key_flag=1;else key_flag=0;
  472.         if( joy & 0xF0 )button_flag=1;else button_flag=0;
  473.  
  474.         /*表示*/
  475.         /* カーソル */
  476.         if( kettei_flag ){
  477.             if(cur1_bg[(++cur_anim)/6]==-1){
  478.                 cur_anim--;
  479.                 end_flag=1;
  480.             }else
  481.                 xobj_set( (2+cur_x)*16, (5+cur_y)*16+8, cur1_bg[cur_anim/6], 0x023F );
  482.         }else{
  483.             if(cur0_bg[(++cur_anim)/6]==-1)cur_anim=0;
  484.             xobj_set( (2+cur_x)*16, (5+cur_y)*16+8, cur0_bg[cur_anim/6], 0x023F );
  485.         }
  486.         /* 文字列 */
  487.         PutBGStr( x1, 16* 4, "LEVEL", INFO_MOJI );    /* LEVEL */
  488.         switch ( level ){
  489.         case 0:
  490.             PutBGStr( 16* 6+x1, 16* 4, "EASY", INFO_MOJI );
  491.             break;
  492.         case 1:
  493.             PutBGStr( 16* 6+x1, 16* 4, "NOMAL", INFO_MOJI );
  494.             break;
  495.         case 2:
  496.             PutBGStr( 16* 6+x1, 16* 4, "HARD", INFO_MOJI );
  497.             break;
  498.         }
  499.         PutBGStr( x2, 16* 5, "LEFT",    INFO_MOJI );PutBGVal0(16* 6+x2, 16* 5,  left1, 1, INFO_MOJI );        /* 1P_LEFT */
  500. /*        PutBGStr( x2, 16* 5, "1P_LEFT", INFO_MOJI );PutBGVal0(16* 8+x2, 16* 5,  left1, 1, INFO_MOJI );*/    /* 1P_LEFT */
  501. /*        PutBGStr( x1, 16* 6, "2P_LEFT", INFO_MOJI );PutBGVal0(16* 8+x1, 16* 6,  left2, 1, INFO_MOJI );*/    /* 2P_LEFT */
  502.         /* 1P BUTON */
  503. /*        PutBGStr( x2, 16* 7, "1P", INFO_MOJI );PutBGStr( x1, 16* 8, "BUTTON", INFO_MOJI );*/
  504.         PutBGStr( x1, 16* 6, "BUTTON", INFO_MOJI );
  505.         if( !player[0].button_swap ){
  506.             PutBGStr( 16* 6+x2, 16* 6, "A:OPTION", INFO_MOJI );
  507.             PutBGStr( 16* 6+x1, 16* 7, "B:SHOT", INFO_MOJI );
  508.         }else{
  509.             PutBGStr( 16* 6+x2, 16* 6, "A:SHOT", INFO_MOJI );
  510.             PutBGStr( 16* 6+x1, 16* 7, "B:OPTION", INFO_MOJI );
  511.         }
  512.         /* 2P BUTON */
  513. /*        PutBGStr( x2, 16* 9, "2P", INFO_MOJI );PutBGStr( x1, 16*10, "BUTTON", INFO_MOJI );
  514.         if( !player[1].button_swap ){
  515.             PutBGStr( 16* 6+x2, 16* 9, "A:OPTION", INFO_MOJI );
  516.             PutBGStr( 16* 6+x1, 16*10, "B:SHOT", INFO_MOJI );
  517.         }else{
  518.             PutBGStr( 16* 6+x2, 16* 9, "A:SHOT", INFO_MOJI );
  519.             PutBGStr( 16* 6+x1, 16*10, "B:OPTION", INFO_MOJI );
  520.         }
  521. */
  522.         PutBGStr( x2, 16* 8, "MUSIC", INFO_MOJI );PutBGVal0(16* 6+x2, 16* 8,  music+1, 2, INFO_MOJI );    /* MUSIC */
  523.         PutBGStr( x1, 16* 9, "SE",    INFO_MOJI );PutBGVal0(16* 6+x1, 16* 9,  se, 2, INFO_MOJI );        /* SE */
  524.         /* XSP_MODE */
  525.         PutBGStr( x2, 16*10, "XSP", INFO_MOJI  );
  526.         switch ( xsp_mode_num ){
  527.         case 1:
  528.             PutBGStr( 16* 6+x1, 16*10, "Low", INFO_MOJI );
  529.             break;
  530.         case 2:
  531.             PutBGStr( 16* 6+x1, 16*10, "Mid", INFO_MOJI );
  532.             break;
  533.         case 3:
  534.             PutBGStr( 16* 6+x1, 16*10, "High", INFO_MOJI );
  535.             break;
  536.         }
  537.         /* DISP_MODE */
  538.         PutBGStr( x2, 16*11, "DISP", INFO_MOJI  );
  539.         switch ( disp_level ){
  540.         case DISP_LEVEL_MID:
  541.             PutBGStr( 16* 6+x1, 16*11, "Mid", INFO_MOJI );
  542.             break;
  543.         case DISP_LEVEL_HIGH:
  544.             PutBGStr( 16* 6+x1, 16*11, "High", INFO_MOJI );
  545.             break;
  546.         }
  547.         PutBGStr( x2, 16*12, "EXIT", INFO_MOJI  );                                        /* EXIT */
  548.  
  549.         xsp_vsync( 1 );
  550.         xsp_out();
  551.         PlaySE();            /* 効果音 */
  552.  
  553.         if( start_flag ){
  554.             if( x1>16*2 ){
  555.                 x1-=10;x2+=10;
  556.             }else{
  557.                 x1=x2=16*2;
  558.                 start_flag=0;
  559.             }
  560.         }
  561.         if( end_flag ){
  562.             if( x2<256+32+16 ){
  563.                 x1-=10;x2+=10;
  564.             }else{
  565.                 init_title_flag=0;
  566.                 break_flag=1;
  567.             }
  568.         }
  569.         if( break_flag )
  570.             break;
  571.     while( BITSNS(0x00) & BIT(0x01) );            /* ESCが離されるまで待つ */
  572.     }
  573.     xsp_mode( xsp_mode_num );
  574. }
  575.  
  576. static void InitTitle( void )
  577. {
  578.     short    gx1=256,gx2=256,x1=5*16+256,x2=5*16-256;
  579.  
  580.     if( init_title_flag ){
  581.         if( init_title_flag > 1 ){
  582.             CRTMOD( 10 );            /* 256*256dot 256色 グラフィックプレーン1枚 31kHz */
  583.             G_CLR_ON();
  584.             MS_CUROF();                /* マウスカーソルを消す */
  585.             SKEY_MOD(0,0,0);
  586.             *(unsigned short *) 0xe82500 = 0b01001001001110;    /* 優先順位 TX>SP>GR */
  587.         }
  588.         xsp_out();                    /* 初期化 */
  589.         SP_ON();                    /* スプライト表示をON */
  590.         B_CLR_AL();                    /* テキスト消去(レーザーなどを消す) */
  591.         BGCTRLST(1, 1, 0);            /* BG1表示OFF */
  592.         /* グラフィック表示 */
  593.         VPAGE(0);
  594.         APAGE(0);apic_load("PIC/TITLE1.PIC",0,0);
  595.         APAGE(1);apic_load("PIC/TITLE2.PIC",0,0);
  596.         HOME( 2, gx1, 0 );
  597.         HOME( 1, gx2, 0 );
  598.         VPAGE(2);
  599.         VPAGE(3);
  600.     }
  601.     PlayBGM( MUSIC_TITLE );        /* 音楽 */
  602.     SetSE(SE_NON);                /* 効果音初期化 */
  603.     for(;x1>=16*5;x1-=8,x2+=8,gx1+=8,gx2-=8){
  604.         PutBGStr( x1, 16* 9, "START", INFO_MOJI );
  605.         PutBGStr( x2, 16*10, "CONTNUE", INFO_MOJI );
  606.         PutBGStr( x1, 16*11, "CONFIG", INFO_MOJI );
  607.         PutBGStr( x2, 16*12, "END", INFO_MOJI );
  608.         xsp_vsync( 1 );
  609.         if( init_title_flag ){
  610.             HOME( 2, gx1, 0 );
  611.             HOME( 1, gx2, 0 );
  612.         }
  613.         xsp_out();
  614.     }
  615.     HOME( 2, 0, 0 );
  616.     HOME( 1, 0, 0 );
  617.  
  618.     cur_x=0;cur_y=0;
  619. }
  620.  
  621. static short Title( void )
  622. {
  623.     void    Opening( void );
  624.     void    InitMapData( void );
  625.     void    game_end( void );
  626.     short    count=0;
  627.     char    joy,cur_anim,key_flag,kettei_flag;
  628.  
  629.     InitTitle();
  630.     init_title_flag=1;
  631.     game_state=IN_TITLE;
  632.     cur_x=0;cur_y=0;cur_anim=0;key_flag=1;kettei_flag=0;
  633.  
  634.     do{
  635.         joy=GetKey( 0,player[0].button_swap );
  636.         if( joy ){
  637.             if( !key_flag && !kettei_flag ){
  638.                 switch (joy){
  639.                 case 1:                    /* 上 */
  640.                     SetSE(SE_PIN);
  641.                     cur_y--;
  642.                     if( cur_y < 0 )cur_y=3;
  643.                     break;
  644.                 case 2:                    /* 下 */
  645.                     SetSE(SE_PIN);
  646.                     cur_y++;
  647.                     if( cur_y > 3 )cur_y=0;
  648.                 }
  649.                 if( joy & B_BUTTON ){        /* 決定 */
  650.                     if( BITSNS(0x00) & BIT(0x03) )stage_select = 1;
  651.                     if( BITSNS(0x00) & BIT(0x04) )stage_select = 2;
  652.                     if( BITSNS(0x00) & BIT(0x05) )stage_select = 3;
  653.                     SetSE(SE_PON);
  654.                     kettei_flag=1;
  655.                     cur_anim=0;
  656.                 }
  657.             }
  658.             key_flag=1;
  659.             count=0;
  660.         }else
  661.             key_flag=0;
  662.         /* 一定時間操作が無いときはオープニング */
  663.         if( count++ > 60*5 ){
  664.             short    con=15;
  665.             FadeOut( 96 );
  666.             while( CONTRAST(-1) != 0 ){
  667.                 if(cur0_bg[(++cur_anim)/6]==-1)cur_anim=0;
  668. /*                xobj_set( (5+cur_x)*16, (10+cur_y)*16+8, cur0_bg[cur_anim/6], 0x023F );*/
  669.                 xsp_vsync( 4 );
  670.                 CONTRAST(--con);
  671. /*                xsp_out();*/
  672.             }
  673.             xsp_out();                    /* 初期化 */
  674.             Opening();
  675.             init_title_flag=2;
  676.             InitTitle();
  677.             count=0;
  678.         }
  679.  
  680.         if( kettei_flag ){
  681.             if(cur1_bg[(++cur_anim)/6]==-1)break;
  682.             xobj_set( (5+cur_x)*16, (10+cur_y)*16+8, cur1_bg[cur_anim/6], 0x023F );
  683.         }else{
  684.             if(cur0_bg[(++cur_anim)/6]==-1)cur_anim=0;
  685.             xobj_set( (5+cur_x)*16, (10+cur_y)*16+8, cur0_bg[cur_anim/6], 0x023F );
  686.         }
  687.         PutBGStr( 16*5, 16* 9, "START", INFO_MOJI );
  688.         PutBGStr( 16*5, 16*10, "CONTNUE", INFO_MOJI );
  689.         PutBGStr( 16*5, 16*11, "CONFIG", INFO_MOJI );
  690.         PutBGStr( 16*5, 16*12, "END", INFO_MOJI );
  691.         xsp_vsync( 1 );
  692.         xsp_out();
  693.         PlaySE();            /* 効果音 */
  694.     }while( kettei_flag!=2 );
  695.  
  696.     return cur_y;
  697. }
  698.  
  699. static void Usage( void )
  700. {
  701.     printf("横スクロールシューティング・ShootingPassion ver1.00\n"
  702.         "\t\t\t\t佐藤幸治 2000/3/31\n"
  703.         "使い方: SPassion [option]\n"
  704.         "[option]\n"
  705.         "-X数値 : xsp_mode (数値 = 1~3, デフォルト = 2)\n"
  706.         "-D数値 : 表示負荷 (数値 = 1~2, デフォルト = 2)\n"
  707.         "-P     : PCMによる効果音を出さない\n"
  708.         "-S     : ジョイスティックABボタン入れ換え\n"
  709.     );
  710. }
  711.  
  712. void main(int ac, char *av[])
  713. {
  714.     void    game_end( void );
  715.     short    i;
  716.  
  717.     xsp_mode_num = 2;
  718.     disp_level     = DISP_LEVEL_HIGH;
  719.     pcm_mode     = 1;            /* 効果音 */
  720.     player[0].button_swap = OFF;
  721.     player[1].button_swap = OFF;
  722.     for (i = 1; i < ac; i++) {
  723.         if( av[1][0] == '-' || av[1][0] == '/' ){
  724.             switch (*(av[i] + 1)) {
  725.             case 'x':
  726.             case 'X':
  727.                 xsp_mode_num = atoi(av[i] + 2);
  728.                 if( xsp_mode_num < 1 )xsp_mode_num=1;
  729.                 if( xsp_mode_num > 3 )xsp_mode_num=3;
  730.                 break;
  731.             case 'd':
  732.             case 'D':
  733.                 disp_level = atoi(av[i] + 2);
  734.                 if( disp_level < 1 )disp_level=1;
  735.                 if( disp_level > 2 )disp_level=2;
  736.                 break;
  737.             case 'p':
  738.             case 'P':
  739.                 pcm_mode=0;
  740.                 break;
  741.             case 's':
  742.             case 'S':
  743.                 player[0].button_swap = ON;
  744.                 break;
  745.             default:
  746.                 Usage();
  747.                 return;
  748.             }
  749.         }
  750.     }
  751.  
  752.     game_state     = !IN_TITLE;
  753.     Init();
  754.     error_level     = ERROR_NON;
  755.     level         = NOMAL;
  756.     game_state     = IN_TITLE;
  757.  
  758.     for(i=0;cur0_bg[i]!=-1;i++)
  759.         cur0_bg[i]+=obj_player;
  760.     for(i=0;cur1_bg[i]!=-1;i++)
  761.         cur1_bg[i]+=obj_player;
  762.  
  763.     left[0].x    =16+16;
  764.     left[0].y    =8+16;
  765.     left[0].pt    = obj_player+21;
  766.     left[0].info=0x023F;
  767.     left[1].x    =232+16;
  768.     left[1].y    =8+16;
  769.     left[1].pt    = obj_player+22;
  770.     left[1].info=0x023F;
  771. /* --------- メインル~プ --------- */
  772.     while(1){
  773.         stage_select=0;
  774.         switch ( Title() ){
  775.         case START:                /* start */
  776.             stage = 0;
  777.             if( stage_select==1 || BITSNS(0x00) & BIT(0x03) )stage = 1;
  778.             if( stage_select==2 || BITSNS(0x00) & BIT(0x04) )stage = 2;
  779.             if( stage_select==3 || BITSNS(0x00) & BIT(0x05) )stage = 3;
  780.             player[0].pow_lev= 0;
  781.             player[1].pow_lev= 0;
  782.             Game();
  783.             break;
  784.         case CONTINUE:            /* continue */
  785.             stage = last_stage;
  786.             Game();
  787.             break;
  788.         case CONFIG:            /* config */
  789.             Config();
  790.             break;
  791.         case END:                /* end */
  792.             game_end();
  793.         }
  794.     }
  795. }
  796.  
  797.  
  798. void game_end( void )
  799. {
  800.     short    x1=16*5+8,x2=16*5-8,gx1=0,gx2=512;
  801.  
  802.     if( !error_level ){
  803.         if( game_state==IN_TITLE ){
  804.             while( gx1<256 ){
  805.                 PutBGStr( x1    , 16* 9, "START", INFO_MOJI );
  806.                 PutBGStr( x2    , 16*10, "CONTNUE", INFO_MOJI );
  807.                 PutBGStr( x1-=10, 16*11, "CONFIG", INFO_MOJI );
  808.                 PutBGStr( x2+=10, 16*12, "END", INFO_MOJI );
  809.                 xsp_vsync( 1 );
  810.                 HOME( 2, gx1+=10, 0 );
  811.                 HOME( 1, gx2-=10, 0 );
  812.                 xsp_out();
  813.             }
  814.         }
  815.         Stop();
  816.         xsp_vsyncint_off();
  817.         pcm8a_vsyncint_off();
  818.         xsp_off();
  819.     }
  820.  
  821.     CRTMOD( 16 );
  822.     KFLUSHIO(0xFF);            /* キーバッファをクリア */
  823.     if( error_message )printf("%s\n",error_message);
  824.     OS_CURON();                /* カーソルを表示する */
  825.     exit(0);
  826. }
  827.  
  828.  
  829. short Pause( void )
  830. {
  831.     char joy,button=0;
  832.  
  833.     pause_flag=1;
  834.     PutBGStr( 16*0, 16* 6, "    P A U S E   ", INFO_MOJI );
  835.     PutBGStr( 16*0, 16* 8, "    Q: TITLE    ", INFO_MOJI );
  836.     PutBGStr( 16*0, 16* 9, "    X: QUIT     ", INFO_MOJI );
  837.     Disp();
  838.     while( BITSNS(0x00) & BIT(0x01) );            /* ESCが離されるまで待つ */
  839.     while( GetKey( 0, player[0].button_swap )&0xF0 );    /* ボタンが離されるまで待つ */
  840.     while( GetKey( 1, player[1].button_swap )&0xF0 );    /* ボタンが離されるまで待つ */
  841.  
  842.     while( 1 ){
  843.         joy=GetKey( 0, player[0].button_swap );
  844.         button=joy&0xF0;
  845.         if( button )break;                            /* ボタンが押されたら出る */
  846.         if( BITSNS(0x00) & BIT(0x01) ){                /* ESCが押されたら出る */
  847.             while( BITSNS(0x00) & BIT(0x01) );
  848.             break;
  849.         }
  850.         if( BITSNS(0x02) & BIT(0x01) ){                /* Q  が押されたら出る */
  851.             FadeOut( 48 );
  852.             CONTRAST(15);
  853.             game_state=IN_TITLE;
  854.             end_stage_work=0;
  855.             game_over_work=0;
  856.             pause_flag=0;
  857.             B_CLR_AL();                /* テキスト消去(レーザーなどを消す) */
  858.             return 0;
  859.         }
  860.         if( BITSNS(0x05) & BIT(0x03) )game_end();    /* X  が押されたら出る */
  861.     }
  862.     player[0].b_button_flag=1;
  863.     pause_flag=0;
  864.     return 1;
  865. }
  866.